<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>指标管理管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<script type="text/javascript">
	$(document).ready(function() {
			var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
			var data = ${fns:toJson(list)}, rootId = 0;
			addRow("#treeTableList", tpl, data, rootId, true);
			$("#treeTable").treeTable({expandLevel : 2});
		});
		function addRow(list, tpl, data, pid, root){
			for (var i=0; i<data.length; i++){
				var row = data[i];
				if ((${fns:jsGetVal('row.indexPId')}) == pid){
					$(list).append(Mustache.render(tpl, {dict: {type:row.indexName,blank123:0}, pid: (root?0:pid), row: row}));
					addRow(list, tpl, data, row.id);
				}
			}
		}
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/index/wtFeedbackIndex/list?templateId=${wtFeedbackIndex.templateId}">指标管理列表</a></li>
		<li><a href="${ctx}/index/wtFeedbackIndex/form?indexPId=0&templateId=${wtFeedbackIndex.templateId}">指标管理添加</a></li>
	</ul>
	
	<sys:message content="${message}"/>
	<table id="treeTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>指标名称</th>
				<th>是否子节点</th>
				<th>指标级别</th>
			   <th>操作</th>
			</tr>
		</thead>
		<tbody id="treeTableList"></tbody>
		</table>
		<script type="text/template" id="treeTableTpl">
		<tr id="{{row.id}}" pId="{{pid}}">
			<td><a href="${ctx}/index/wtFeedbackIndex/form?id={{row.id}}">
				{{row.indexName}}
			</a>
			</td>
			<td>
				{{row.indexLeafName}}
			</a>
			<td>
				{{row.indexLevel}}
			</a>
			</td>
			<td>
   				<a href="${ctx}/index/wtFeedbackIndex/form?id={{row.id}}" style="{{hidden}}">修改</a>
				<a href="${ctx}/index/wtFeedbackIndex/delete?id={{row.id}}&templateId=${wtFeedbackIndex.templateId}" style="{{hidden}}" onclick="return confirmx('确认要删除该指标维护成功及所有子指标维护成功吗？', this.href)">删除</a>
				<a href="${ctx}/index/wtFeedbackIndex/form?indexPId={{row.id}}&templateId=${wtFeedbackIndex.templateId}">添加下级指标维护成功</a> 
			</td>
		</tr>
	</script>
	
	
</body>
</html>